package xframe.util;

import java.util.ArrayList;
import java.util.HashMap;

/**
 * Created by IntelliJ IDEA.
 * User: kbs
 * Date: 2005. 11. 8
 * Time: 오후 12:08:16
 */
public class Spread {

    public final static char[] SPREAD_NOT_SUPPORT_CHAR = {'\'', '\"', 'º'};
    public final static String[] SPREAD_CAN_SUPPORT_CHAR = {"'\\\'", "\\\"", "º"};

    //TextTip
    public final static int TextTipOff = 0;
    public final static int TextTipFixed = 1;
    public final static int TextTipFloating = 2;
    public final static int TextTipFixedFocusOnly = 3;
    public final static int TextTipFocus = 4;

    // Action property settings
    public final static int ACTION_ACTIVE_CELL = 0;
    public final static int ACTION_GOTO_CELL = 1;
    public final static int ACTION_SELECT_BLOCK = 2;
    public final static int ACTION_CLEAR = 3;
    public final static int ACTION_DELETE_COL = 4;
    public final static int ACTION_DELETE_ROW = 5;
    public final static int ACTION_INSERT_COL = 6;
    public final static int ACTION_INSERT_ROW = 7;
    public final static int ACTION_RECALC = 11;
    public final static int ACTION_CLEAR_TEXT = 12;
    public final static int ACTION_PRINT = 13;
    public final static int ACTION_DESELECT_BLOCK = 14;
    public final static int ACTION_DSAVE = 15;
    public final static int ACTION_SET_CELL_BORDER = 16;
    public final static int ACTION_ADD_MULTISELBLOCK = 17;
    public final static int ACTION_GET_MULTI_SELECTION = 18;
    public final static int ACTION_COPY_RANGE = 19;
    public final static int ACTION_MOVE_RANGE = 20;
    public final static int ACTION_SWAP_RANGE = 21;
    public final static int ACTION_CLIPBOARD_COPY = 22;
    public final static int ACTION_CLIPBOARD_CUT = 23;
    public final static int ACTION_CLIPBOARD_PASTE = 24;
    public final static int ACTION_SORT = 25;
    public final static int ACTION_COMBO_CLEAR = 26;
    public final static int ACTION_COMBO_REMOVE = 27;
    public final static int ACTION_RESET = 28;
    public final static int ACTION_SEL_MODE_CLEAR = 29;
    public final static int ACTION_VMODE_REFRESH = 30;
    public final static int ACTION_SMARTPRINT = 32;

    // BackColorStyle property settings
    public final static int BACKCOLORSTYLE_OVERGRID = 0;
    public final static int BACKCOLORSTYLE_UNDERGRID = 1;
    public final static int BACKCOLORSTYLE_OVERHORZGRIDONLY = 2;
    public final static int BACKCOLORSTYLE_OVERVERTGRIDONLY = 3;

    // ButtonDrawMode property settings
    public final static int BDM_ALWAYS = 0;
    public final static int BDM_CURRENT_CELL = 1;
    public final static int BDM_CURRENT_COLUMN = 2;
    public final static int BDM_CURRENT_ROW = 4;

    // Cell Color settings
    public final static String COLOR_WHITE = "0x00FFFFFF";
    public final static String COLOR__BRIGHT_GRAY = "0x00E0E0E0";
    public final static String COLOR_GRAY1 = "0x00C0C0C0";
    public final static String COLOR_GRAY2 = "0x00808080";
    public final static String COLOR_DARK_GRAY = "0x00404040";
    public final static String COLOR_BLACK = "0x00000000";
    public final static String COLOR_BRIGHT1_RED = "0x00C0C0FF";
    public final static String COLOR_BRIGHT2_RED = "0x008080FF";
    public final static String COLOR_RED = "0x000000FF";
    public final static String COLOR_BRIGHT1_ORANGE = "0x00C0E0FF";
    public final static String COLOR_BRIGHT2_ORANGE = "0x0080C0FF";
    public final static String COLOR_ORANGE = "0x000080FF";
    public final static String COLOR_BRIGHT1_YELLOW = "0x00C0FFFF";
    public final static String COLOR_BRIGHT2_YELLOW = "0x0080FFFF";
    public final static String COLOR_YELLOW = "0x0000FFFF";
    public final static String COLOR_BRIGHT1_GREEN = "0x00C0FFC0";
    public final static String COLOR_BRIGHT2_GREEN = "0x0080FF80";
    public final static String COLOR_GREEN = "0x0000FF00";
    public final static String COLOR_BRIGHT_BLUE1 = "0x00FFFFC0";
    public final static String COLOR_BRIGHT_BLUE2 = "0x00FFFF80";
    public final static String COLOR_BRIGHT_VIOLET = "0x00FFC0C0";
    public final static String COLOR_VIOLET = "0x00FF8080";
    public final static String COLOR_BLUE = "0x00FF0000";

    // CellBorderStyle property settings
    public final static int BORDER_STYLE_DEFAULT = 0;
    public final static int BORDER_STYLE_SOLID = 1;
    public final static int BORDER_STYLE_DASH = 2;
    public final static int BORDER_STYLE_DOT = 3;
    public final static int BORDER_STYLE_DASH_DOT = 4;
    public final static int BORDER_STYLE_DASH_DOT_DOT = 5;
    public final static int BORDER_STYLE_BLANK = 6;
    public final static int BORDER_STYLE_FINE_SOLID = 11;
    public final static int BORDER_STYLE_FINE_DASH = 12;
    public final static int BORDER_STYLE_FINE_DOT = 13;
    public final static int BORDER_STYLE_FINE_DASH_DOT = 14;
    public final static int BORDER_STYLE_FINE_DASH_DOT_DOT = 15;

    // CellBorderType property settings
    public final static int BORDER_TYPE_NONE = 0;
    public final static int BORDER_TYPE_OUTLINE = 16;
    public final static int BORDER_TYPE_LEFT = 1;
    public final static int BORDER_TYPE_RIGHT = 2;
    public final static int BORDER_TYPE_TOP = 4;
    public final static int BORDER_TYPE_BOTTOM = 8;

    // CellType property settings
    public final static int CELL_TYPE_DATE = 0;
    public final static int CELL_TYPE_EDIT = 1;
    public final static int CELL_TYPE_FLOAT = 2;
    public final static int CELL_TYPE_INTEGER = 3;
    public final static int CELL_TYPE_PIC = 4;
    public final static int CELL_TYPE_STATIC_TEXT = 5;
    public final static int CELL_TYPE_TIME = 6;
    public final static int CELL_TYPE_BUTTON = 7;
    public final static int CELL_TYPE_COMBOBOX = 8;
    public final static int CELL_TYPE_PICTURE = 9;
    public final static int CELL_TYPE_CHECKBOX = 10;
    public final static int CELL_TYPE_OWNER_DRAWN = 11;
    public final static int CELL_TYPE_CURRENCY = 12;
    public final static int CELL_TYPE_NUMBER = 13;
    public final static int CELL_TYPE_PERCENT = 14;

    // ColHeaderDisplay and RowHeaderDisplay property settings
    public final static int HEADER_BLANK = 0;
    public final static int HEADER_NUMBERS = 1;
    public final static int HEADER_LETTERS = 2;

    // CursorStyle property settings
    public final static int CURSOR_STYLE_USER_DEFINED = 0;
    public final static int CURSOR_STYLE_DEFAULT = 1;
    public final static int CURSOR_STYLE_ARROW = 2;
    public final static int CURSOR_STYLE_DEFCOLRESIZE = 3;
    public final static int CURSOR_STYLE_DEFROWRESIZE = 4;

    // CursorType property settings
    public final static int CURSOR_TYPE_DEFAULT = 0;
    public final static int CURSOR_TYPE_COLRESIZE = 1;
    public final static int CURSOR_TYPE_ROWRESIZE = 2;
    public final static int CURSOR_TYPE_BUTTON = 3;
    public final static int CURSOR_TYPE_GRAYAREA = 4;
    public final static int CURSOR_TYPE_LOCKEDCELL = 5;
    public final static int CURSOR_TYPE_COLHEADER = 6;
    public final static int CURSOR_TYPE_ROWHEADER = 7;

    // DAutoSize property settings
    public final static int AUTOSIZE_NO = 0;
    public final static int AUTOSIZE_MAX_COL_WIDTH = 1;
    public final static int AUTOSIZE_BEST_GUESS = 2;

    // EditEnterAction property settings
    public final static int CELL_EDITMODE_EXIT_NONE = 0;
    public final static int CELL_EDITMODE_EXIT_UP = 1;
    public final static int CELL_EDITMODE_EXIT_DOWN = 2;
    public final static int CELL_EDITMODE_EXIT_LEFT = 3;
    public final static int CELL_EDITMODE_EXIT_RIGHT = 4;
    public final static int CELL_EDITMODE_EXIT_NEXT = 5;
    public final static int CELL_EDITMODE_EXIT_PREVIOUS = 6;
    public final static int CELL_EDITMODE_EXIT_SAME = 7;
    public final static int CELL_EDITMODE_EXIT_NEXTROW = 8;

    // OperationMode property settings
    public final static int OP_MODE_NORMAL = 0;
    public final static int OP_MODE_READONLY = 1;
    public final static int OP_MODE_ROWMODE = 2;
    public final static int OP_MODE_SINGLE_SELECT = 3;
    public final static int OP_MODE_MULTI_SELECT = 4;
    public final static int OP_MODE_EXT_SELECT = 5;

    // Position property settings
    public final static int POSITION_UPPER_LEFT = 0;
    public final static int POSITION_UPPER_CENTER = 1;
    public final static int POSITION_UPPER_RIGHT = 2;
    public final static int POSITION_CENTER_LEFT = 3;
    public final static int POSITION_CENTER_CENTER = 4;
    public final static int POSITION_CENTER_RIGHT = 5;
    public final static int POSITION_BOTTOM_LEFT = 6;
    public final static int POSITION_BOTTOM_CENTER = 7;
    public final static int POSITION_BOTTOM_RIGHT = 8;

    // PrintOrientation property settings
    public final static int PRINTORIENT_DEFAULT = 0;
    public final static int PRINTORIENT_PORTRAIT = 1;
    public final static int PRINTORIENT_LANDSCAPE = 2;

    // PrintType property settings
    public final static int PRINT_ALL = 0;
    public final static int PRINT_CELL_RANGE = 1;
    public final static int PRINT_CURRENT_PAGE = 2;
    public final static int PRINT_PAGE_RANGE = 3;

    // ScrollBars property settings
    public final static int SCROLLBAR_NONE = 0;
    public final static int SCROLLBAR_H_ONLY = 1;
    public final static int SCROLLBAR_V_ONLY = 2;
    public final static int SCROLLBAR_BOTH = 3;

    // ScrollBarExtMode property settings
    // SelectBlockOptions property settings
    public final static int SELBLOCKOPT_COLS = 1;
    public final static int SELBLOCKOPT_ROWS = 2;
    public final static int SELBLOCKOPT_BLOCKS = 4;
    public final static int SELBLOCKOPT_ALL = 8;

    // SortBy property settings
    public final static int SORT_BY_ROW = 0;
    public final static int SORT_BY_COL = 1;

    // SortKeyOrder property settings
    public final static int SORT_ORDER_NONE = 0;
    public final static int SORT_ORDER_ASCENDING = 1;
    public final static int SORT_ORDER_DESCENDING = 2;

    // TypeButtonAlign property settings
    public final static int CELL_BUTTON_ALIGN_BOTTOM = 0;
    public final static int CELL_BUTTON_ALIGN_TOP = 1;
    public final static int CELL_BUTTON_ALIGN_LEFT = 2;
    public final static int CELL_BUTTON_ALIGN_RIGHT = 3;

    // TypeButtonType property settings
    public final static int CELL_BUTTON_NORMAL = 0;
    public final static int CELL_BUTTON_TWO_STATE = 1;

    // TypeCheckTextAlign property settings
    public final static int CHECKBOX_TEXT_LEFT = 0;
    public final static int CHECKBOX_TEXT_RIGHT = 1;

    // TypeCheckType property settings
    public final static int CHECKBOX_NORMAL = 0;
    public final static int CHECKBOX_THREE_STATE = 1;

    // TypeDateFormat property settings
     //'OCT-01-YYYY'  : 0
    public final static int CELL_DATE_FORMAT_DDMONYY = 0;
     //'DD-MM-YYYY' : 1
    public final static int CELL_DATE_FORMAT_DDMMYY = 1;
     //'MM-DD-YYYY' : 2
    public final static int CELL_DATE_FORMAT_MMDDYY = 2;
     //'YYYY-MM-DD' : 3
    public final static int CELL_DATE_FORMAT_YYMMDD = 3;
     //'제어판설정내용대로' : 99
    public final static int CELL_DATE_FORMAT_DEFALT = 99; //Resets to use the Date Format setting in the Windows Control Panel TypeDateFormatDefault

    // TypeEditCharCase property settings
    public final static int CELL_EDIT_CASE_LOWER_CASE = 0;
    public final static int CELL_EDIT_CASE_NO_CASE = 1;
    public final static int CELL_EDIT_CASE_UPPER_CASE = 2;

    // TypeEditCharSet property settings
    public final static int CELL_EDIT_CHAR_SET_ASCII = 0;
    public final static int CELL_EDIT_CHAR_SET_ALPHA = 1;
    public final static int CELL_EDIT_CHAR_SET_ALPHANUMERIC = 2;
    public final static int CELL_EDIT_CHAR_SET_NUMERIC = 3;

    // TypeHAlign property settings
    public final static int CELL_H_ALIGN_LEFT = 0;
    public final static int CELL_H_ALIGN_RIGHT = 1;
    public final static int CELL_H_ALIGN_CENTER = 2;

    // TypeTextAlignVert property settings
    public final static int CELL_STATIC_V_ALIGN_BOTTOM = 0;
    public final static int CELL_STATIC_V_ALIGN_CENTER = 1;
    public final static int CELL_STATIC_V_ALIGN_TOP = 2;

    // TypeVAlign Property settings
    public final static int CELL_V_ALIGN_TOP = 0;
    public final static int CELL_V_ALIGN_BOTTOM = 1;
    public final static int CELL_V_ALIGN_VCENTER = 2;

    // TypeTime24Hour property settings
    public final static int CELL_TIME_12_HOUR_CLOCK = 0;
    public final static int CELL_TIME_24_HOUR_CLOCK = 1;

    // UnitType property settings
    public final static int CELL_UNIT_NORMAL = 0;
    public final static int CELL_UNIT_VGA = 1;
    public final static int CELL_UNIT_TWIPS = 2;

    // UserResize property settings
    public final static int USER_RESIZE_COL = 1;
    public final static int USER_RESIZE_ROW = 2;

    // UserResizeCol and UserResizeRow property settings
    public final static int USER_RESIZE_DEFAULT = 0;
    public final static int USER_RESIZE_ON = 1;
    public final static int USER_RESIZE_OFF = 2;

    // VScrollSpecialType property settings
    public final static int VSCROLLSPECIAL_NO_HOME_END = 1;
    public final static int VSCROLLSPECIAL_NO_PAGE_UP_DOWN = 2;
    public final static int VSCROLLSPECIAL_NO_LINE_UP_DOWN = 4;

    // AddCustomFunctionExt method Flags parameter settings
    public final static int CUSTFUNC_WANTCELLREF = 1;
    public final static int CUSTFUNC_WANTRANGEREF = 2;

    // CFGetParamInfo method Type parameter settings
    public final static int VALUE_TYPE_LONG = 0;
    public final static int VALUE_TYPE_DOUBLE = 1;
    public final static int VALUE_TYPE_STR = 2;
    public final static int VALUE_TYPE_CELL = 3;
    public final static int VALUE_TYPE_RANGE = 4;

    // CFGetParamInfo method Status parameter settings
    public final static int VALUE_STATUS_OK = 0;
    public final static int VALUE_STATUS_ERROR = 1;
    public final static int VALUE_STATUS_EMPTY = 2;

    // GetRefStyle/SetRefStyle methods return values/parameter settings
    public final static int REFSTYLE_DEFAULT = 0;
    public final static int REFSTYLE_A1 = 1;
    public final static int REFSTYLE_R1C1 = 2;

    //  TypeEditCharSet Property
    public final static int TypeEditCharSetASCII = 0; //(Default) Any character
    public final static int TypeEditCharSetAlpha = 1; //A-Z, a-z, space
    public final static int TypeEditCharSetAlphanumeric = 2; //A?Z, a?z, 0?9, period, comma, space, minus sign (?)
    public final static int TypeEditCharSetNumeric = 3; //0?9, period, minus sign (?)




    //Searches a column for a specified value or string.

    //Searches for exact match to complete text in cell, but ignores cases
    public final static int SearchFlagsNone = 0;
    //Search for text or a value greater than or equal to the specified text or value
    public final static int SearchFlagsGreaterOrEqual = 1;
    //Search for text that matches or partially matches the specified text
    public final static int SearchFlagsPartialMatch = 2;
    //Searches for text as if the text provided is equivalent to using the Value property
    public final static int SearchFlagsValue = 4;
    //Search for text that exactly matches the text and case specified
    public final static int SearchFlagsCaseSensitive = 8;
    //Use for searching in columns that are sorted in ascending order. The method works more rapidly on a sorted column if you specify this setting.
    public final static int SearchFlagsSortedAscending = 16;
    //Use for searching in columns that are sorted in descending order. The method works more rapidly on a sorted column if you specify this setting.
    public final static int SearchFlagsSortedDescending = 32;


    /*
     0 - Off (Default)  TextTipOff
     1 -  TextTipFixed
     2 -TextTipFloating
     3 - TextTipFixedFocusOnly
     4 - Floating   Focus  Only When the control has the focus, control displays text
    */

    //Cell align property
    public int Top = 0;
    public int Left = 0;
    public int Bottom = 1;
    public int Right = 1;
    public int Center = 2;

    /**
     * DOCUMENT ME!
     *
     * @param Row DOCUMENT ME!
     * @param Col DOCUMENT ME!
     * @param Text DOCUMENT ME!
     * @param ColWidth DOCUMENT ME!
     * @param isSort DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
    public  static String setHeader(int Row, int Col, String Text,
                                         int ColWidth, boolean isSort) {
        return "setHeader( " + Row + ", " + Col + ", '" + Text + "', "
        + ColWidth + "," + isSort + ");";
    }

    /**
     * DOCUMENT ME!
     *
     * @param Row DOCUMENT ME!
     * @param Col DOCUMENT ME!
     * @param Text DOCUMENT ME!
     * @param CellType DOCUMENT ME!
     * @param TextTip DOCUMENT ME!
     * @param VAlign DOCUMENT ME!
     * @param HAlign DOCUMENT ME!
     * @param isLock DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
    public  static String setData(int Row, int Col, String Text,
                                       int CellType, String TextTip, int VAlign, int HAlign, boolean isLock) {
        return "setData(" + Row + " ," + Col + ",'" + Text + "'," + CellType
        + "," + TextTip + "," + VAlign + "," + HAlign + "," + isLock + "  );";
    }

    /**
     * DOCUMENT ME!
     *
     * @param Row DOCUMENT ME!
     * @param Col DOCUMENT ME!
     * @param isLock DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
    public  static String cellLock(int Row, int Col, boolean isLock) {
        return "cellLock(" + Row + "," + Col + "," + isLock + ");";
    }

    /**
     * DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
    public  static String searchSelected() {
        return "searchSelected();";
    }

    /**
     * DOCUMENT ME!
     *
     * @param addRowNum DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
    public  static String simpleAddRow(int addRowNum) {
        return "simpleAddRow(" + addRowNum + ");";
    }

    /**
     * DOCUMENT ME!
     *
     * @param Row DOCUMENT ME!
     * @param Col DOCUMENT ME!
     * @param Text DOCUMENT ME!
     * @param TypeDateFormat DOCUMENT ME!
     * @param ISLOCK DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
    public  static String setCellTypeDATE(int Row, int Col, String Text,
                                               int TypeDateFormat, boolean ISLOCK) {
        return "setCellTypeDATE(" + Row + ", " + Col + ", " + Text + ", "
        + TypeDateFormat + "," + ISLOCK + ");";
    }

    /**
     * DOCUMENT ME!
     *
     * @param Row DOCUMENT ME!
     * @param Col DOCUMENT ME!
     * @param Text DOCUMENT ME!
     * @param TypePicMask DOCUMENT ME!
     * @param H_ALIGN DOCUMENT ME!
     * @param ISLOCK DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
    public  static String setCellTypePIC(int Row, int Col, int Text,
                                              String TypePicMask, int H_ALIGN, boolean ISLOCK) {
        return "setCellTypePIC(" + Row + "," + Col + "," + Text + ", "
        + TypePicMask + " ," + H_ALIGN + "," + ISLOCK + ");";
    }

    /**
     * DOCUMENT ME!
     *
     * @param Row DOCUMENT ME!
     * @param Col DOCUMENT ME!
     * @param Text DOCUMENT ME!
     * @param H_ALIGN DOCUMENT ME!
     * @param ISLOCK DOCUMENT ME!
     * @param ISHIDDEN DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
    public  static String setCellTypeEDIT(int Row, int Col, String Text,
                                               int H_ALIGN, boolean ISLOCK, boolean ISHIDDEN) {
        return "setCellTypeEDIT(" + Row + ", " + Col + ", " + Text + ","
        + H_ALIGN + "," + ISLOCK + " ," + ISHIDDEN + ");";
    }

    /**
     * DOCUMENT ME!
     *
     * @param Row DOCUMENT ME!
     * @param Col DOCUMENT ME!
     * @param Text DOCUMENT ME!
     * @param H_ALIGN DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
    public  static String setCellTypeStaticText(int Row, int Col,
                                                     String Text, int H_ALIGN) {
        return "setCellTypeStaticText(" + Row + "," + Col + "," + Text + ","
        + H_ALIGN + " );";
    }

    /**
     * DOCUMENT ME!
     *
     * @param Row DOCUMENT ME!
     * @param Col DOCUMENT ME!
     * @param Text DOCUMENT ME!
     * @param TypeTime24Hour DOCUMENT ME!
     * @param ISShowScecond DOCUMENT ME!
     * @param ISLOCK DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
    public  static String setCellTypeTime(int Row, int Col, String Text,
                                               int TypeTime24Hour, boolean ISShowScecond, boolean ISLOCK) {
        return "setCellTypeTime (" + Row + "," + Col + "," + Text + ","
        + TypeTime24Hour + ", " + ISShowScecond + "," + ISLOCK + " );";
    }

    /**
     * DOCUMENT ME!
     *
     * @param Row DOCUMENT ME!
     * @param Col DOCUMENT ME!
     * @param TypeButtonText DOCUMENT ME!
     * @param TypeButtonAlign DOCUMENT ME!
     * @param isTwoState DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
    public  static String setCellTypeButton(int Row, int Col,
                                                 String TypeButtonText, int TypeButtonAlign, boolean isTwoState) {
        return "setCellTypeButton(" + Row + "," + Col + ", " + TypeButtonText
        + ", " + TypeButtonAlign + "," + isTwoState + ");";
    }

    /**
     * DOCUMENT ME!
     *
     * @param Row DOCUMENT ME!
     * @param Col DOCUMENT ME!
     * @param isCheck DOCUMENT ME!
     * @param Text DOCUMENT ME!
     * @param H_ALIGN DOCUMENT ME!
     * @param ISLOCK DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
    public  static String setCellTypeCheckBox(int Row, int Col,
                                                   int isCheck, String Text, int H_ALIGN, boolean ISLOCK) {
        return "setCellTypeCheckBox (" + Row + ", " + Col + ", " + isCheck
        + "," + Text + "," + H_ALIGN + "," + ISLOCK + ");";
    }

    /**
     * DOCUMENT ME!
     *
     * @param Row DOCUMENT ME!
     * @param Col DOCUMENT ME!
     * @param obj DOCUMENT ME!
     * @param isEditable DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
    public  static String setCellTypeComboBox(int Row, int Col,
                                                   String obj, boolean isEditable) {
        return "setCellTypeComboBox(" + Row + "," + Col + "," + obj + ","
        + isEditable + " );";
    }

    /**
     * DOCUMENT ME!
     *
     * @param Row DOCUMENT ME!
     * @param Col DOCUMENT ME!
     * @param Text DOCUMENT ME!
     * @param TypeCurrencyDecPlaces DOCUMENT ME!
     * @param TypeCurrencyMax DOCUMENT ME!
     * @param TypeCurrencyMin DOCUMENT ME!
     * @param ISLOCK DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
    public  static String setCellTypeCurrency(int Row, int Col,
                                                   String Text, int TypeCurrencyDecPlaces, int TypeCurrencyMax,
                                                   int TypeCurrencyMin, boolean ISLOCK) {
        return "setCellTypeCurrency(" + Row + "," + Col + "," + Text + ","
        + TypeCurrencyDecPlaces + "," + TypeCurrencyMax + "," + TypeCurrencyMin
        + "," + ISLOCK + ");";
    }

    /**
     * DOCUMENT ME!
     *
     * @param Row DOCUMENT ME!
     * @param Col DOCUMENT ME!
     * @param Text DOCUMENT ME!
     * @param TypeNumberDecPlaces DOCUMENT ME!
     * @param TypeNumberMax DOCUMENT ME!
     * @param TypeNumberMin DOCUMENT ME!
     * @param IsCommaOk DOCUMENT ME!
     * @param ISLOCK DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
    public  static String setCellTypeNumber(int Row, int Col, String Text,
                                                 int TypeNumberDecPlaces, int TypeNumberMax, int TypeNumberMin,
                                                 int IsCommaOk, boolean ISLOCK) {
        return "setCellTypeNumber(" + Row + "," + Col + "," + Text + ","
        + TypeNumberDecPlaces + "," + TypeNumberMax + "," + TypeNumberMin + ","
        + IsCommaOk + "," + ISLOCK + ");";
    }

    /**
     * DOCUMENT ME!
     *
     * @param Row DOCUMENT ME!
     * @param Col DOCUMENT ME!
     * @param Text DOCUMENT ME!
     * @param TypePercentDecPlaces DOCUMENT ME!
     * @param TypePercentMax DOCUMENT ME!
     * @param TypePercentMin DOCUMENT ME!
     * @param TypeNegRed DOCUMENT ME!
     * @param ISLOCK DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
    public  static String setCellTypePercent(int Row, int Col,
                                                  String Text, int TypePercentDecPlaces, int TypePercentMax,
                                                  int TypePercentMin, int TypeNegRed, boolean ISLOCK) {
        return "setCellTypePercent(" + Row + "," + Col + "," + Text + ","
        + TypePercentDecPlaces + "," + TypePercentMax + "," + TypePercentMin
        + "," + TypeNegRed + "," + ISLOCK + ");";
    }

     public  static String clipDataSet(int Row, int Col, int Row2, int Col2, ArrayList arrList, String ColumName){
        StringBuffer sb_data = new StringBuffer();
        StringBuffer sb_returnValue = new StringBuffer();

        for(int i  = 0 ; i <arrList.size() ; i++){
                HashMap hm =   (HashMap)arrList.get(i);
                sb_data.append(UtilMaster.null2Empty((String) hm.get(ColumName)));
                sb_data.append("\\r\\n");
            }

         sb_returnValue.append("spreadObject.Col = "+Col+";\n");
         sb_returnValue.append("spreadObject.Row = "+Row+";\n");
         sb_returnValue.append("spreadObject.Col2 = "+Col2+";\n");
         sb_returnValue.append("spreadObject.Row2 = "+Row2+";\n");
         sb_returnValue.append("spreadObject.Clip = '"+converSpecialChar(sb_data+"", Spread.SPREAD_NOT_SUPPORT_CHAR)+"';\n");

        //return  UtilMaster.converSpecialChar(sb_returnValue+"", Spread.SPREAD_NOT_SUPPORT_CAHR);
         return  sb_returnValue+"";
    }

    public  static String clipDataSet2(int Row, int Col, int Row2, int Col2, ArrayList arrList, String ColumName){
        StringBuffer sb_data = new StringBuffer();
        StringBuffer sb_returnValue = new StringBuffer();

        for(int i  = 0 ; i <arrList.size() ; i++){
                HashMap hm =   (HashMap)arrList.get(i);
                sb_data.append(UtilMaster.null2Empty((String) hm.get(ColumName)));
                sb_data.append("\\r\\n");
            }

         sb_returnValue.append("spreadObject.Col = "+Col+";\n");
         sb_returnValue.append("spreadObject.Row = "+Row+";\n");
         sb_returnValue.append("spreadObject.Col2 = "+Col2+";\n");
         sb_returnValue.append("spreadObject.Row2 = "+Row2+";\n");
         sb_returnValue.append("spreadObject.Clip = '"+converSpecialChar(sb_data+"", Spread.SPREAD_NOT_SUPPORT_CHAR)+"';\n");

        //return  UtilMaster.converSpecialChar(sb_returnValue+"", Spread.SPREAD_NOT_SUPPORT_CAHR);
         return  sb_returnValue+"";
    }

     public  static String clipDataSet(int Row, int Col, int Row2, int Col2, ArrayList arrList, String[] columNameArr, int ColumIndex, String[] selectBoxColumName){
        StringBuffer sb_data = new StringBuffer();
        StringBuffer sb_returnValue = new StringBuffer();
    String[] columNameArr_1 = new String[columNameArr.length];
         columNameArr_1 = columNameArr;


         for(int i  = 0 ; i <arrList.size() ; i++)
         {
             HashMap hm =   (HashMap)arrList.get(i);
             for(int j=0; j < selectBoxColumName.length; j++)
             {
                 for(int k = 0 ; k < columNameArr.length ; k++ )
                 {
                     if(columNameArr[k].equals(selectBoxColumName[j]) )
                     {
                         columNameArr_1[k]="";
                     }
                 }
             }
             if(!columNameArr_1[ColumIndex].equals(""))
             {
                 sb_data.append((String) hm.get(columNameArr[ColumIndex]));
                 sb_data.append("\\r\\n");
             }
         }

         sb_returnValue.append("spreadObject.Col = "+Col+";\n");
         sb_returnValue.append("spreadObject.Row = "+Row+";\n");
         sb_returnValue.append("spreadObject.Col2 = "+Col2+";\n");
         sb_returnValue.append("spreadObject.Row2 = "+Row2+";\n");
         sb_returnValue.append("spreadObject.Clip = '"+converSpecialChar(sb_data+"", Spread.SPREAD_NOT_SUPPORT_CHAR)+"';\n");

        return  sb_returnValue+"";
    }

    public  static String getColumNameArr(String[] columNameArr){
          StringBuffer sb_returnValue = new StringBuffer();
         sb_returnValue.append("\n");
         sb_returnValue.append("\n");
         sb_returnValue.append("//각 컬럼의 이름을 배열로 선언해주면 스크립트 해당 폼의 객체를 생성해 준다.\n");
         sb_returnValue.append("//Input 객체를 만드는 이름 명입니다..\n");
         sb_returnValue.append("columNameArr  = new Array();\n");
         for(int i  = 0 ; i <columNameArr.length ; i++){
               sb_returnValue.append("columNameArr["+i+"]  ='"+columNameArr[i]+"';\n");
         }
         return  sb_returnValue+"";
    }

    public  static String setCellTypeInBlock(
                                                                                    int Row, int Col, int Row2, int Col2,
                                                                                    int CellType, String Text_OR_Selected,
                                                                                    int MaxLength, int MinLength,
                                                                                    int HAlign , String PicMask_OR_DateFormat_OR_Array,
                                                                                    boolean isLock){
        StringBuffer sb_returnValue = new StringBuffer();
        sb_returnValue.append("spreadObject.Col = "+Col+";\n");
         sb_returnValue.append("spreadObject.Row = "+Row+";\n");
         sb_returnValue.append("spreadObject.Col2 = "+Col2+";\n");
         sb_returnValue.append("spreadObject.Row2 = "+Row2+";\n");
         sb_returnValue.append("spreadObject.BlockMode =true ;\n");
         sb_returnValue.append("spreadObject.CellType = "+CellType+";\n");
         sb_returnValue.append("spreadObject.TypeVAlign(2);\n");
         sb_returnValue.append("spreadObject.TypeHAlign("+HAlign +");\n");
        sb_returnValue.append("spreadObject.Lock("+isLock+") ;\n");

            switch(CellType){
                case 0 : //DateFormat
                             sb_returnValue.append("spreadObject.TypeDateFormat = "+PicMask_OR_DateFormat_OR_Array+";\n");
                             sb_returnValue.append("spreadObject.TypeSpin = true;\n");
                             sb_returnValue.append("spreadObject.TypeSpinInc = 1;\n");
                              break;

                case 1://Edit Type
                               sb_returnValue.append("spreadObject.TypeEditCharSet('"+PicMask_OR_DateFormat_OR_Array +"');\n");
                               sb_returnValue.append("spreadObject.value = '"+Text_OR_Selected +"';\n");
                               sb_returnValue.append("spreadObject.TypeMaxEditLen("+MaxLength +");\n");
                               sb_returnValue.append("spreadObject.EditEnterAction =8;\n");
                               sb_returnValue.append("spreadObject.ProcessTab(true);\n");
                                break;

                 case 4:// Cell Type을 PIC 타입으로 변환
                                sb_returnValue.append("spreadObject.TypePicMask='"+PicMask_OR_DateFormat_OR_Array+"';\n");
                                sb_returnValue.append("spreadObject.TypeHAlign("+HAlign +");\n");
                                 break;

                 case 6://  Cell Type을Time 타입으로 변환
                                sb_returnValue.append("spreadObject.text = '"+Text_OR_Selected +"';\n");
                                sb_returnValue.append("spreadObject.TypeTime24Hour = '"+PicMask_OR_DateFormat_OR_Array +"';\n");
                                sb_returnValue.append("spreadObject.TypeTimeSeconds = false;\n");
                                sb_returnValue.append("spreadObject.TypeSpin = true;\n");
                                sb_returnValue.append("spreadObject.TypeSpinInc = 1;\n");
                                 break;

                 case 7://Cell Type을 Button 타입으로 변환
                                 sb_returnValue.append("spreadObject.TypeButtonAlign("+HAlign+");\n");
                                 sb_returnValue.append("spreadObject.TypeButtonText ='"+Text_OR_Selected+"' ;\n");
                            //    PicMask_OR_DateFormat_OR_Array 이 '1' 이면 2state 로 바뀐다.
                                    if(PicMask_OR_DateFormat_OR_Array.equals("1")){
                                        sb_returnValue.append("spreadObject.TypeButtonType(1) ;\n");
                                    }

                                  break;

                case 8:// Cell Type을 ComboBox  타입으로 변환
                                  sb_returnValue.append("spreadObject.TypeComboBoxList='"+PicMask_OR_DateFormat_OR_Array+"';\n");
                                  sb_returnValue.append("spreadObject.TypeComboBoxCurSel='"+Text_OR_Selected+"';\n");
                                   sb_returnValue.append("spreadObject.TypeComboBoxEditable =false;\n");
                                   sb_returnValue.append("spreadObject.TypeComboBoxAutoSearch =3;\n");
                                   break;

                 case 10://Cell Type을 CheckBox  타입으로 변환하는 함수.
                                 sb_returnValue.append("spreadObject.TypeCheckText = '"+PicMask_OR_DateFormat_OR_Array+"' ;\n");
                                   if(HAlign ==2){
                                        sb_returnValue.append("spreadObject.TypeCheckCenter =true;\n");
                                   }else{
                                        sb_returnValue.append("spreadObject.TypeCheckCenter =false;\n");
                                   }
                                    if(Text_OR_Selected.equals("1")){
                                        sb_returnValue.append("spreadObject.value =1;\n");
                                    }else{
                                        sb_returnValue.append("spreadObject.value =0;\n");
                                    }
                                  break;

                   case 12://Cell Type을 Currency  타입으로 변환
                                      sb_returnValue.append("spreadObject.TypeCurrencyShowSymbol=false;\n");
                                      sb_returnValue.append("spreadObject.TypeCurrencyShowSep=true;\n");
                                      sb_returnValue.append("spreadObject.value ='"+Text_OR_Selected+"' ;\n");
                                      sb_returnValue.append("spreadObject.TypeCurrencyDecPlaces ="+PicMask_OR_DateFormat_OR_Array+";\n");
                                      sb_returnValue.append("spreadObject.TypeCurrencyMax ="+MaxLength+";\n");
                                      sb_returnValue.append("spreadObject.TypeCurrencyMin ="+MinLength+";\n");
                                      sb_returnValue.append("spreadObject.TypeSpin =true;\n");
                                      sb_returnValue.append("spreadObject.TypeSpinInc =1000;\n");
                                      break;

                  case  13:// Cell Type을 Number  타입으로 변환
                                      sb_returnValue.append("spreadObject.TypeNumberMax ="+MaxLength+";\n");
                                      sb_returnValue.append("spreadObject.TypeNumberMin ="+MinLength+";\n");
                                      sb_returnValue.append("spreadObject.TypeNumberShowSep(true);\n");
                                      sb_returnValue.append("spreadObject.TypeNumberDecPlaces("+PicMask_OR_DateFormat_OR_Array+");\n");
                                      sb_returnValue.append("spreadObject.TypeSpin =true;\n");
                                      sb_returnValue.append("spreadObject.TypeSpinInc =1;\n");
                                       break;

                  case 14://  Cell Type을 Percent  타입으로 변환
                                       sb_returnValue.append("spreadObject.Text = '"+Text_OR_Selected+"';\n");
                                       sb_returnValue.append("spreadObject.TypePercentNegStyle(2);\n");
                                       sb_returnValue.append("spreadObject.TypePercentDecPlaces("+PicMask_OR_DateFormat_OR_Array+");\n");
                                       sb_returnValue.append("spreadObject.TypePercentMax("+MaxLength+");\n");
                                       sb_returnValue.append("spreadObject.TypePercentMin("+MinLength+");\n");
                                       sb_returnValue.append("spreadObject.TypeSpin =true;\n");
                                       sb_returnValue.append("spreadObject.TypeSpinInc =1;\n");
                                       sb_returnValue.append("spreadObject.TypeNegRed(true);\n");
            }

           sb_returnValue.append("spreadObject.TypeEllipses(true) ;\n");
           sb_returnValue.append("spreadObject.AllowCellOverflow(false) ;\n");
           sb_returnValue.append("spreadObject.BlockMode =false ;\n");
               return    sb_returnValue+"";
    }

    public static String converSpecialChar(String inputText, char[] specialChar){
        for(int i = 0 ; i < specialChar.length ; i++){
            String delimeter = Character.toString(specialChar[i]);
              /*   if(delimeter.equals("º")){
                    inputText =  inputText.replaceAll(delimeter,"\\\\"+"'");
                 }else{
                   inputText =  inputText.replaceAll(delimeter,"\\\\"+delimeter);
                 }
            */
            inputText =  UtilMaster.replace(inputText,delimeter,SPREAD_CAN_SUPPORT_CHAR[i]);
        }
        return inputText;
    }
}
